import java.util.Scanner;

//链接：https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf?tpId=230&tqId=2021480&ru=/exam/oj&qru=/ta/dynamic-programming/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D196
//前缀和:  模板 一维数组前缀和
//牛客DP34 JZ
public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        //1.读入数据
        int n = in.nextInt();
        int m = in.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 0; i < n; i++) {
            arr[i + 1] = in.nextInt();
        }

        //2.预处理前缀和数组
        long[] sum = new long[n + 1];//防溢出
        for (int i = 1; i <= n; i++) {
            sum[i] = arr[i] + sum[i - 1];
        }

        //3.使用前缀和数组
        while (m > 0) {
            int l = in.nextInt();
            int r = in.nextInt();

            System.out.println(sum[r] - sum[l - 1]);
            m--;
        }

    }
}
